﻿namespace DotNetStar.OpenSDK
{
    /// <summary>
    /// 表示开放平台中的客户端应用配置。
    /// </summary>
    public class ClientConfig
    {
        /// <summary>
        /// 使用指定的应用 Id 和密钥初始化 <see cref="ClientConfig"/> 类的新实例。
        /// </summary>
        /// <param name="clientId">客户端应用的唯一编号。</param>
        /// <param name="clientKey">客户端应用的密钥字符串。</param>
        public ClientConfig(string clientId, string clientKey)
        {
            ClientId = clientId;
            ClientKey = clientKey;
        }

        /// <summary>
        /// 获取客户端应用指定的 Id。
        /// </summary>
        public string ClientId { get; }
        /// <summary>
        /// 获取客户端应用的密钥字符串。
        /// </summary>
        public string ClientKey { get; }

        /// <summary>
        /// Returns a <see cref="System.String" /> that represents this instance.
        /// </summary>
        /// <returns>
        /// A <see cref="System.String" /> that represents this instance.
        /// </returns>
        public override string ToString()
        => $"{this.ClientId}_{this.ClientKey}";

        /// <summary>
        /// Returns a hash code for this instance.
        /// </summary>
        /// <returns>
        /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. 
        /// </returns>
        public override int GetHashCode() => this.ToString().GetHashCode();

        /// <summary>
        /// Determines whether the specified <see cref="System.Object" />, is equal to this instance.
        /// </summary>
        /// <param name="obj">The <see cref="System.Object" /> to compare with this instance.</param>
        /// <returns>
        ///   <c>true</c> if the specified <see cref="System.Object" /> is equal to this instance; otherwise, <c>false</c>.
        /// </returns>
        public override bool Equals(object obj) => this.GetHashCode() == ((ClientConfig)obj).GetHashCode();
        
    }
}
